package cn.chinaunicom.sdsi.gacx.quartz;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import cn.chinaunicom.sdsi.frm.sys.sysinit.utils.SpringContextUtil;
import cn.chinaunicom.sdsi.gacx.quartz.service.QuartzService;
import cn.chinaunicom.sdsi.gacx.quartz.service.impl.QuartzServiceImpl;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @Description: 任务执行类
 * 
 * @ClassName: QuartzJob
 * @Copyright: Copyright (c) 2014
 * 
 * @author chenxl
 * @date 2017-07-29 
 * @version V1.0
 */
@Component
public class Job_SpeAreaCount implements Job {

	private final String jobId = "1";
	private QuartzService  quartzService;

	@Override
	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		System.out.println("开始执行Job_SpeAreaCount ======" + "★★★★★★★★★★★");
		quartzService = (QuartzService)SpringContextUtil.getBean("quartzService");
		JSONObject jObject =quartzService.getJobTaskByJobId(jobId);
		JSONArray cronArray = jObject.getJSONArray("data");
		
		for (int i = 0; i < cronArray.size(); i++) {
			JSONObject job = cronArray.getJSONObject(i);
			
			String taskId = job.getString("taskId");
			String areaId = job.getString("areaId");
			String value = job.getString("value");
			String jobId = job.getString("jobId");
					
			System.out.println("taskId====="+taskId);
		}
        
	}
}